package uy.swnoc.controller;

import org.omnifaces.util.Faces;

import javax.enterprise.context.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import java.io.Serializable;
import java.util.Locale;

/**
 * User: rmartony
 * Date: 17/12/13
 * Time: 06:39 PM
 */
@Named
@SessionScoped
public class LocaleController implements Serializable {
    private Locale locale = Faces.getLocale();

    public Locale getLocale() {
        return locale;
    }

    public String getLanguage() {
        return locale.getLanguage();
    }

    public void setLanguage(String language) {
        locale = new Locale(language);
        FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
    }

}